print("郭枫2020211001000105")
money = int(input("请输入您的总资产："))
while 1:
    print("下面是商品展示：")
    goods = [
        {"name": "书包", "price": 19},
        {"name": "鼠标", "price": 60},
        {"name": "房子", "price": 100000},
        {"name": "自行车", "price": 998},
        {"name":"饮料","price":6}
    ]
       
    for i in range(len(goods)):
        print(i + 1, goods[i]["name"], goods[i]["price"])
    remove = input("是否要将商品移除购物车,请回答Y或者N: ").upper()
    if remove == "Y":
        remove_shopping = input("请输入要移除的商品序号: ")
        del goods[int(remove_shopping)]["name"]
        print("您的购物列表如下: ")
        for j in range(len(goods)):
            print(j)
            break
    elif remove == "N":
        print("取消移除")
    dictOne = {}
    sumAccount = 0
    while 1:
        aOne = input("请输入您选择的商品序号（如您已经加入购物车完毕，请输入Q退出）：").upper()
        if aOne == "Q":
            break
        else:
            aTwo = input("请输入您选择的商品份数：")
            dictOne[aOne] = aTwo
            print("您将购买{}，购买的份数为{}份".format(goods[int(aOne) - 1]["name"], aTwo))
            totalAccount = goods[int(aOne) - 1]["price"] * int(aTwo)
            sumAccount = sumAccount + totalAccount

    print("您购买的商品总价为：" + str(sumAccount))
    if sumAccount <= int(money):
        print("购买成功！您的资产剩余为：{}".format((int(money) - sumAccount)))
    else:
        print("您的余额不足，购买失败！")
        recharge = input("请您确认是否需要充值，输入Y充值，N退出充值：").upper()
        if recharge=="Y":
            money = money +int(input("输入充值的金额:"))
        else:
            money = money - sumAccount
    sure = input("请您确认是否还要购买，输入Y继续，N退出程序：").upper()
    if sure == "N":
        break
